package xixirupan.tmgp.tencent.com.vmeim.ui.beautyshop.model.categorydetailbean;

import android.util.Log;

import java.util.HashMap;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import xixirupan.tmgp.tencent.com.vmeim.config.URLConfig;
import xixirupan.tmgp.tencent.com.vmeim.retrofit.ICategoryDtailR;

/**
 * Created by lenovo on 2016/10/25.
 */

public class CategoryDataBiz {


    IPostDeatiData postDeatiData ;
    String cid =43+"";
    public  void getData(String cid, final IPostDeatiData postDeatiData)
    {
        this.postDeatiData =postDeatiData;
        this.cid =cid;
        Retrofit retrofit =new Retrofit.Builder().baseUrl(URLConfig.Url.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        ICategoryDtailR iCategoryDtailR = retrofit.create(ICategoryDtailR.class);
        HashMap<String,String> map =new HashMap<>();
        map.put("cid",cid);
        Call<CatogryDetailBean> call = iCategoryDtailR.getDetailData(map);
        call.enqueue(new Callback<CatogryDetailBean>() {
            @Override
            public void onResponse(Call<CatogryDetailBean> call, Response<CatogryDetailBean> response) {
                CatogryDetailBean body = response.body();
                DetailDataBean data = body.getData();
                List<ProductsBaen> products = data.getProducts();
                Log.i("目录详情页面","---------->"+products.size());

                postDeatiData.postData(products);

            }

            @Override
            public void onFailure(Call<CatogryDetailBean> call, Throwable t) {
                Log.i("目录详情页面加载失败","---------->"+t.getMessage());

            }
        });
    }
}
